package savet.gui.tabelas;

import com.toedter.calendar.DateUtil;
import com.toedter.calendar.JCalendar;
import com.toedter.calendar.JDateChooser;
import com.toedter.calendar.JDateChooserCellEditor;
import com.toedter.calendar.JTextFieldDateEditor;
import java.awt.Component;
import java.util.Date;
import javax.swing.AbstractCellEditor;
import javax.swing.JTable;
import javax.swing.table.TableCellEditor;

/**
 *
 * @author Adisson Marinho
 */
public class DateCellEditor extends AbstractCellEditor implements TableCellEditor {

    private JDateChooser dateChooser;

    public DateCellEditor() {
        dateChooser = new JDateChooser("dd/MM/yyyy", "##/##/####", '_');
    }

    public Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int row, int column) {
        Date data = null;

        if (value instanceof Date)
            data = (Date) value;

        dateChooser.setDate(data);

        return dateChooser;
    }

    public Object getCellEditorValue() {
        return dateChooser.getDate();
    }

}
